#include <CGAL/Polyhedron_3.h>
#include <CGAL/extract_mean_curvature_flow_skeleton.h>
#include <CGAL/boost/graph/IO/STL.h>

using Kernel = CGAL::Simple_cartesian<double>;
using Polyhedron = CGAL::Polyhedron_3<Kernel>;
using Skeleton = CGAL::Mean_curvature_flow_skeletonization<Polyhedron>::Skeleton;

int main()
{
    Polyhedron mesh;

    CGAL::IO::read_STL("/run/media/sunny/data/datasets/Thingi10K/raw_meshes/32770.stl", mesh);

    if (!CGAL::is_triangle_mesh(mesh))
    {
        std::cerr << "Not triangle mesh\n";
        return 1;
    }

    Skeleton skeleton;

    CGAL::extract_mean_curvature_flow_skeleton(mesh, skeleton);

    std::cout << num_vertices(skeleton) << " " << num_edges(skeleton) << "\n";

    for (auto v : CGAL::make_range(vertices(skeleton)))
        std::cout << skeleton[v].point << "\n";

    for (auto e : CGAL::make_range(edges(skeleton)))
        std::cout << source(e, skeleton) << " " << target(e, skeleton) << "\n";

    return 0;
}
